<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back"></a>
			<h1 class="mui-title">全部新闻</h1>
		</header>
		<div class="mui-content">
	
					<ul class="mui-table-view" id="lists">
						<!--<li class="mui-table-view-cell mui-media">
							<a href="javascript:;">
								<img class="mui-media-object mui-pull-right" src="imgs/cbd.jpg">
								<div class="mui-media-body">
									远眺
									<p class="mui-ellipsis">静静的看这个世界，最后终于疯了</p>
								</div>
							</a>
						</li>-->
					</ul>				
		</div>
		
		
		<script src="js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init();
			
//			window.addEventListener('refresh', function(e) {  
//		        location.reload();  
//		        console.log("重新刷新了");
//		        //document.getElementById('indexHeader').innerHTML = 'Hello World';  
//		    })  
			
			mui.plusReady(function(){
				//列表页跳详情页
				var prPage = mui.preload({
		  		url: 'info.html',
		  		id: 'info.html'
		  	}); 		  		  		
  		  		reloadAllNews();		
  		  		
			});

			function reloadAllNews(){
				mui.ajax('http://172.20.10.8:8080/news',{
					data:{
					},
					dataType:'json',
					type:'get',
					timeout:10000, 
					success:function(data){
						
					var str = '';
					for(var i=0;i<data.length;i++){
						console.log("进来了全部的请求");
					str = str + '<li class="mui-table-view-cell mui-media" id="'+data[i].id+'"><a href="javascript:;"><img class="mui-media-object mui-pull-right" src="'+data[i].img+'"><div class="mui-media-body">'+data[i].title+'<p class="mui-ellipsis">'+data[i].info+'</p></div></a></li>';
					}
					var lists = document.getElementById('lists');
					lists.innerHTML = str;
					
					var prPage = mui.preload({
		  		  		url: 'info.html',
		  		  		id: 'info.html'
		  		  	});
							
					mui('#lists').on('tap','li',function(){
						
						var this_ = this;
						var index = this_.id;
						console.log(index);
						
		  		  		mui.fire(prPage,'newsinfo',{
		  		  			'id': index
		  		  		});
		  		  		mui.openWindow({
		  		  			url: 'info.html',
		  		  			id: 'info.html'
		  		  		});
		  		  	  });
		  		  		
					
					},
					error:function(xhr,type,errorThrown){
						console.log(type);
					}
				});
			}
			
		</script>
	</body>

</html>